package com.likou.smart;

public class Solution1109 {
    public int[] corpFlightBookings(int[][] bookings, int n) {
        int [] result = new int[n];
        for (int[] rows:bookings){
            result[rows[0]-1]+=rows[2];
            if(rows[1]<n)
                result[rows[1]]-=rows[2];
        }
        for(int i=1;i<n;i++) {
            result[i]=result[i-1]+result[i];
        }
        return result;
    }

    public static void main(String[] args) {
        int[][] bookings = new int[3][3];
        int n =5;

        bookings[0][0] = 1;
        bookings[0][1] = 2;
        bookings[0][2] = 10;

        bookings[1][0] = 2;
        bookings[1][1] = 3;
        bookings[1][2] = 20;

        bookings[2][0] = 2;
        bookings[2][1] = 5;
        bookings[2][2] = 25;
        System.out.println(new Solution1109().corpFlightBookings(bookings,n));
    }
}
